<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"   pageEncoding="UTF-8"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<c:url value="resources/css/item.css"/>" >
</head>
<h1>Products</h1>
<table class="search">
<tr>
	<th width="100">Name</th>
	<th width="100">Price</th>
	<th width="100">Stock</th>
</tr>
    
<c:forEach var="product" items="${products}" varStatus="status">
    <tr>
    <c:url var="prodUrl" value="products/view" >
 		<c:param name="itemId" value="${product.productId}" />
    </c:url>
    <td>
        <a href='<c:out value="${prodUrl}"/>'>${product.name}</a>
    </td>
    <fmt:formatNumber value="${product.actualPrice/100}"  var="priceString" type="currency" currencySymbol="$"/>
   <td  style="text-align: center;"><c:out value="${priceString}" /></td>
   <td  style="text-align: center;"><c:out value="${product.stock}" /></td>
    </tr>
</c:forEach>
</table>
<table>
<tr>
<c:if test="${lastPageNum>1}">
<c:forEach var="i" begin="1" end="${lastPageNum}" varStatus="status">
	<c:url var="pageUrl" value="products" >
 		<c:param name="categoryId" value="${categoryId}" />
 		<c:param name="pageNum" value= "${i}" />
    </c:url>
    	<td><a href='<c:out value="${pageUrl}"/>'>${i}</a></td>	
</c:forEach>
</c:if>
</tr>
</table>
</html>